package com.smart.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.smart.pojo.Finance;
import com.smart.pojo.ResultBean;
import com.smart.req.PageData;
import com.smart.req.SalaryReq;
import com.smart.resp.SalaryResp;
import com.smart.service.IFinanceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author lyj
 * @since 2023-05-17
 */
@RestController
@RequestMapping("/finance")
public class FinanceController {

    @Autowired
    private IFinanceService financeService;

    @GetMapping("queryByCondition")
    public ResultBean queryByCondition(Integer type, PageData pageData) {
        System.out.println("查询财务记录状态：" + type + "，" + pageData);
        Page<Finance> page = new Page<>(pageData.getPageNum(), pageData.getPageSize());
        financeService.lambdaQuery()
                .eq(!ObjectUtils.isEmpty(type), Finance::getType, type)
                .page(page);
        return ResultBean.success(page);
    }

    @GetMapping("queryAll")
    public ResultBean queryALl() {
        System.out.println("获取全部财务记录");
        return ResultBean.success(financeService.list());
    }
}
